<%@ page import="com.wwdx.shiro.SessionUser" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/public/inc/tags.jsp"%>
<html>
<head>
    <jsp:include page="/public/inc/head.jsp"/>
</head>
<body>
<div id="header" class="navbar navbar-static-top" role="navigation">
    <jsp:include page="/public/inc/top.jsp"/>
</div>
<div class="container-fluid" style="margin-top:5px;margin-bottom:60px;">
    <div class="row">
        <jsp:include page="/public/inc/menu.jsp"/>
        <div class="col-xs-12 col-sm-10">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <div class="media">
                        <div class="media-body">
                            <span class="glyphicon glyphicon-list"></span>阅读包管理
                        </div>
                        <shiro:hasAnyRoles name="super,admin">
                            <div class="media-right">
                                <a href="/system/wwdx_theme/create" class="btn btn-primary">
                                    <span class="glyphicon glyphicon-plus"></span> 阅读包添加
                                </a>
                            </div>
                        </shiro:hasAnyRoles>
                    </div>
                </div>
                <div class="panel-body">
                    <div class="form-inline">
                        <form action="/system/wwdx_theme/list">
                            <label>
                                <select name="type" class="form-control">
                                    <option value="">类型</option>
                                    <option value="1" <c:if test="${type eq 1}"> selected="selected"</c:if>>书单包</option>
                                    <option value="0" <c:if test="${type eq 0}"> selected="selected"</c:if>>精品课</option>
                                </select>
                            </label>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <label>
                                <select name="status" class="form-control">
                                    <option value="">是否上线</option>
                                    <option value="1" <c:if test="${status eq 1}">selected</c:if>>否</option>
                                    <option value="0" <c:if test="${status eq 0}">selected</c:if>>是</option>
                                </select>
                            </label>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            编号: <input type="text" class="form-control" name="themeid" placeholder="编号"/>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            名称: <input type="text" class="form-control" name="title" placeholder="名称"/>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <button type="submit" class="btn btn-primary">筛选</button>
                        </form>
                    </div>
                </div>
                <div class="table-responsive">
                    <table class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>封面</th>
                            <th>编号</th>
                            <th>名称</th>
                            <th>类型</th>
                            <th>启用</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="l" items="${list}" varStatus="status">
                            <tr>
                                <td>
                                        ${status.count}
                                </td>
                                <td>
                                    <img src="http://img.readerday.com/cover/${l.img}"
                                         style="height: 70px;width: 70px;">
                                </td>
                                <td>
                                        ${l.themeid}
                                </td>
                                <td>
                                        ${l.title}
                                </td>
                                <td>
                                    <c:choose>
                                        <c:when test="${l.type eq 0 }">
                                            <span class="btn btn-danger btn-xs">精品课</span>
                                        </c:when>
                                        <c:when test="${l.type eq 1 }">
                                            <span class="btn btn-primary btn-xs">书单列表</span>
                                        </c:when>
                                    </c:choose>
                                </td>
                                <td>
                                    <c:choose>
                                        <c:when test="${l.status eq 0 }">
                                            <span class="btn btn-danger btn-xs">是</span>
                                        </c:when>
                                        <c:when test="${l.status eq 1 }">
                                            <span class="btn btn-primary btn-xs">否</span>
                                        </c:when>
                                    </c:choose>
                                </td>
                                <td>
                                    <shiro:hasAnyRoles name="super,admin">
                                        <c:choose>
                                            <c:when test="${l.type eq 0 }">
                                                <a class="btn btn-primary btn-xs"
                                                   href="/system/wwdx_banner/create?id=${l.themeid}&bannertype=6">
                                                    <span class="glyphicon glyphicon-heart"></span>推荐首页
                                                </a>
                                            </c:when>
                                            <c:when test="${l.type eq 1 }">
                                                <a class="btn btn-primary btn-xs"
                                                   href="/system/wwdx_banner/create?id=${l.themeid}&bannertype=12">
                                                    <span class="glyphicon glyphicon-heart"></span>推荐首页
                                                </a>
                                            </c:when>
                                        </c:choose>
                                        <a class="btn btn-primary btn-xs"
                                           href="/system/wwdx_theme/book_list?themeid=${l.themeid}">
                                            <span class="glyphicon glyphicon-search"></span> 主题下的书
                                        </a>
                                        <a class="btn btn-primary btn-xs"
                                           href="/system/wwdx_theme/createCDKEY?themeid=${l.themeid}">
                                            <span class="glyphicon glyphicon-plus"></span> 兑换码
                                        </a>
                                        <a class="btn btn-primary btn-xs"
                                           href="/system/wwdx_theme/edit?id=${l.id}">
                                            <span class="glyphicon glyphicon-pencil"></span> 修改
                                        </a>
                                    </shiro:hasAnyRoles>
                                    <c:if test='<%=SessionUser.getMerchantId() != null && !"".equals(SessionUser.getMerchantId())%>'>
                                        <a class="btn btn-primary btn-xs"
                                           href="/system/wwdx_merchant_product/save?type=2&product_id=${l.themeid}&merchant_id=<%=SessionUser.getMerchantId()%>">
                                            <span class="glyphicon glyphicon-plus"></span>添加分销产品
                                        </a>
                                    </c:if>
                                    <shiro:hasRole name="super">
                                        <a class="btn btn-danger btn-xs" onclick="del('${l.id}');">
                                            <span class="glyphicon glyphicon-trash"></span> 删除
                                        </a>
                                    </shiro:hasRole>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
                <div class="panel-footer">
                    <p:pagination url="/system/wwdx_theme/list" total="${listSize}"/>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="/public/inc/bottom.jsp"/>
</body>
</html>
<script type="text/javascript">
    function del(id) {
        var msg = "您确认要删除吗？";
        if (window.confirm(msg)) {
            window.location.href = "/system/wwdx_theme/delete?id=" + id;
        }
    }
</script>